﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    /// <summary>
    /// 用户数据访问类
    /// </summary>
    public class UserInfoDAL
    {
        SqlCommand cmd = new SqlCommand();//定义Command对象

        /// 用户登录验证方法
        public bool UserLogin(string userid,string password)
        {
            cmd.CommandType = System.Data.CommandType.Text;//查询方式选用SQL语句
            cmd.CommandText = "SELECT *  FROM UserInfo WhERE userid='"+userid+"' and pwd='"+password+"'";

            try
            {
                object returnResult = DBHelper.GetScalar(cmd);//创建returnResult对象，存储SQL执行结果
                if (Convert.ToInt64(returnResult) > 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }

            }
            catch(Exception ex)
            {
                throw ex;
            }
        }
    }
}
